package top.healthylife.gateway.platform.br.api.api.basicdata;


import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.br.api.utils.GetmeltingTokenUtils;
import top.healthylife.gateway.platform.br.dto.basicdata.idcarddelongsto.req.BrReqIdCardDelongsToDto;
import top.healthylife.gateway.platform.br.dto.basicdata.idcarddelongsto.res.BrResIdCardDelongsToDto;

/**
 * @author cl
 * @version 1.0
 * @date 2020/4/22 17:08
 */
@Slf4j
@Service
@ApiServiceExplain( docUrl="https://account-self.100credit.com/", price = 20,apiName = "身份证号手机号归属地", info = "查询身份证号和手机号所属地区")
public class IdCardDelongsToApi implements ParentFace<BrReqIdCardDelongsToDto, BrResIdCardDelongsToDto> {
    /**
     * 接口唯一标识
     */
    static final String APIIDENTIFICATION = "KeyAttribution";

    /**
     * 接口版本号
     */
    static final String VESION = "1.0";

    @Override
    public BrResIdCardDelongsToDto execute(BrReqIdCardDelongsToDto brDemoApi){
        //访问百融获取数据
        String apiData = GetmeltingTokenUtils.getApiData(APIIDENTIFICATION, VESION
                , BeanUtil.beanToMap(brDemoApi), GetmeltingTokenUtils.systemConfigInfo(brDemoApi));
        return JSON.parseObject(apiData, BrResIdCardDelongsToDto.class);
    }
}
